#ifndef TIPWIDGET_H
#define TIPWIDGET_H

#include <QWidget>
#include <QLabel>
#include <QTimer>
#include <QPropertyAnimation>
#include <QHBoxLayout>
#include <QPixmap>
#include<QPaintEvent>
#include<QMediaPlayer>
class TipWidget : public QWidget
{
    Q_OBJECT

public:
    enum TipType { Info, Warning, Error };

    // 获取单例
    static TipWidget* getInstance();
    static void release();
    ~TipWidget();
    // 显示提示
    void showTip(const QString& text, TipType type = Info, int duration = 1000, QWidget* parent = nullptr);

protected:
    explicit TipWidget(QWidget *parent = nullptr);
    void paintEvent(QPaintEvent *event);
private:
    static TipWidget* m_instance;       //声明

    QLabel* m_iconLabel;
    QLabel* m_textLabel;
    QTimer* m_timer;
    QPropertyAnimation* m_fadeAnimation;

    void setupUI();

    QMediaPlayer *m_player=nullptr;
};

#endif // TIPWIDGET_H
